


#ifndef __client_base_h__
#define __client_base_h__

#include "../dqnetwork/packet.h"
#include "../dqnetwork/Inetwork.h"

#include <boost/bind.hpp>
#include <boost/thread.hpp>
#include <functional>
#include "../dqmsg/base_msg.h"
#include <iostream>
#include <windows.h>

class BaseClientSocketMgr
{
	friend class BaseClientNetMgr;
public:
	BaseClientSocketMgr(){};
	virtual ~BaseClientSocketMgr(){};
public:
	virtual bool OnConnect() {return true;};
	virtual bool OnClose() { return true;};
	virtual bool OnGetMsg(int msgid,const std::string& data){return true;};
public:
    bool SendData(const packet &data);
public:
	bool DealData2Msg(packet &data);
    bool SendMsg(DQMSG& msg);
protected:
	virtual bool OnGetData(packet& data) { return true;};
private:
	Isocket *socket_;
};




class BaseClientNetMgr
{
private:
	BaseClientNetMgr(){};
public:
	static BaseClientNetMgr& getsingle(){
		static BaseClientNetMgr static_s;
		return static_s;
	}
public:
	bool start();
	bool run();
	bool stop();
	bool manager(BaseClientSocketMgr *c );
private:
   static void client_connect_callback(Isocket* which_connect,bool& accept,bool& finishaccept);
    void check_recv_data();
private:
	Inetwork *network_;
	Isocket *sockets_;
private:
	
	BaseClientSocketMgr*  client_;
};










#endif //__client_base_h__